import { syncSetTimeout, sendMessage, getMessage, dispatch } from "../../global/tools.js";

export default class AjaxHook {
    static count = 0;
    constructor(webController) {
        AjaxHook.count++;
        if (AjaxHook.count >= 2) {
            alert("collectionPlugin: \nError: AjaxHook.count >= 2，即将刷新页面。");
            location.reload(true);
        } 
        this.webController = webController;
        this.init();
    }
    init() {
        ah.proxy({
            onRequest: (config, handler) => {
                this.onRequest(config);
                handler.next(config);
            },
            onError: (err, handler) => {
                this.onError(err);
                handler.next(err);
            },
            onResponse: (response, handler) => {
                this.onResponse(response);
                handler.next(response);
            }
        })
    }
    onRequest(config) {

    }
    onError(err) {

    }
    onResponse(response) {
    }
}